/*
 * Anamnese.java
 *
 * Created on October 12, 2007, 10:46 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package petstore.model;

import java.util.Date;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * Entity class Anamnese
 * 
 * @author Tom Hayden
 */
@Entity
@Table(name = "anamnese")
@AttributeOverrides( {
    @AttributeOverride(name="id", column=@Column(name="nranamnese")),
    @AttributeOverride(name="description", column=@Column(name="txanamnese")),
    @AttributeOverride(name="active", column=@Column(name="ativo"))
})
public class Anamnese extends CodeData {

    @Column(name = "dtanamnese")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dataAnamnese;

    @ManyToOne
    @JoinColumn(name="cdanimal")
    private Animal animal;
    
    /** Creates a new instance of Anamnese */
    public Anamnese() {
    }
    
    public String getBriefDescription() {
        String result = this.description;
        if (this.description.length() > 20) {
            result = this.getDescription().substring(0, 20).concat("...");
        }
        return result;
    }

    public Date getDataAnamnese() {
        return dataAnamnese;
    }

    public void setDataAnamnese(Date dataAnamnese) {
        this.dataAnamnese = dataAnamnese;
    }

    public Animal getAnimal() {
        return animal;
    }

    public void setAnimal(Animal animal) {
        this.animal = animal;
    }
    
}
